package com.ruoyi.wechat.api;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysDictData;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.service.ISysDictTypeService;
import com.ruoyi.wechat.domain.WxActivity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * 字典列表Controller
 *
 * @author ruoyi
 * @date 2024-07-24
 */
@Api(value = "字典列表", tags = {"字典列表"})
@RestController
@RequestMapping("/wechat/dict")
public class WxDictController extends BaseController {

    @Autowired
    private ISysDictTypeService dictTypeService;



    /**
     * 根据字典类型查询字典数据信息
     */
    @ApiOperation(value = "根据dictType字典列表，获取该字典对应的值", response = WxActivity.class)
    @GetMapping(value = "/type/{dictType}")
    public AjaxResult dictType(@PathVariable String dictType)
    {
        List<SysDictData> data = dictTypeService.selectDictDataByType(dictType);
        if (StringUtils.isNull(data))
        {
            data = new ArrayList<SysDictData>();
        }
        return success(data);
    }
}
